package com.zjc.springboot.delayqueue.config;

import com.zjc.springboot.delayqueue.listener.RedisExpiredListener;
import com.zjc.springboot.delayqueue.redis.RedisClient;
import com.zjc.springboot.zk.slice.ZookeeperClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;

@Configuration
public class AutoConfig {

    @Autowired
    ZookeeperClient zookeeperClient;

    @Autowired
    StringRedisTemplate stringRedisTemplate;

    @Autowired
    ApplicationContext applicationContext;

    @Bean
    RedisClient redisClient() {
        return new RedisClient(stringRedisTemplate);
    }

    @Bean
    RedisExpiredListener redisExpiredListener() {
        return new RedisExpiredListener(applicationContext, zookeeperClient, redisClient());
    }

}
